package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yanjing.domain.LaborProtectionItems;
import com.ruoyi.yanjing.service.ILaborProtectionItemsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 劳保用品发放记录信息Controller
 * 
 * @author whz
 * @date 2024-12-04
 */
@RestController
@RequestMapping("/yanjing/items")
public class LaborProtectionItemsController extends BaseController
{
    @Autowired
    private ILaborProtectionItemsService laborProtectionItemsService;

    /**
     * 查询劳保用品发放记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:list')")
    @GetMapping("/list")
    public TableDataInfo list(LaborProtectionItems laborProtectionItems)
    {
        startPage();
        List<LaborProtectionItems> list = laborProtectionItemsService.selectLaborProtectionItemsList(laborProtectionItems);
        return getDataTable(list);
    }

    /**
     * 导出劳保用品发放记录信息列表
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:export')")
    @Log(title = "劳保用品发放记录信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LaborProtectionItems laborProtectionItems)
    {
        List<LaborProtectionItems> list = laborProtectionItemsService.selectLaborProtectionItemsList(laborProtectionItems);
        ExcelUtil<LaborProtectionItems> util = new ExcelUtil<LaborProtectionItems>(LaborProtectionItems.class);
        util.exportExcel(response, list, "劳保用品发放记录信息数据");
    }

    /**
     * 获取劳保用品发放记录信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(laborProtectionItemsService.selectLaborProtectionItemsById(id));
    }

    /**
     * 新增劳保用品发放记录信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:add')")
    @Log(title = "劳保用品发放记录信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LaborProtectionItems laborProtectionItems)
    {
        return toAjax(laborProtectionItemsService.insertLaborProtectionItems(laborProtectionItems));
    }

    /**
     * 修改劳保用品发放记录信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:edit')")
    @Log(title = "劳保用品发放记录信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LaborProtectionItems laborProtectionItems)
    {
        return toAjax(laborProtectionItemsService.updateLaborProtectionItems(laborProtectionItems));
    }

    /**
     * 删除劳保用品发放记录信息
     */
    @PreAuthorize("@ss.hasPermi('yanjing:items:remove')")
    @Log(title = "劳保用品发放记录信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(laborProtectionItemsService.deleteLaborProtectionItemsByIds(ids));
    }
}
